<?php

namespace app\admin\controller;

use app\BaseController;
use app\common\entity\ResponseData;
use app\common\exception\auth\UnLoginException;
use think\Model;

class AdminBase extends BaseController
{
    protected Model $model;
    protected function initialize()
    {
//        if (!defined('IS_LOGIN') || !IS_LOGIN) {
//            throw new UnLoginException();
//        }
    }

    public function getListColumns()
    {
        $columns = [
            [
                'key' => 'name',
                'dataKey' => 'name',
                'title' => '角色名称',
                'editable' => true,
                'width' => 120,
            ],
            [
                'key' => 'create_time',
                'dataKey' => 'create_time',
                'title' => '创建时间',
                'width' => 150,
            ],
            [
                'key' => 'status',
                'dataKey' => 'status',
                'title' => '状态',
                'width' => 150,
                'isSwitch' => true,
                'switchOpen' => 1,
                'switchClose' => 0,
            ],
        ];
        if(method_exists($this,'getListColumnDiy')) {
            $columns = $this->getListColumnDiy($columns);
        }
        if (method_exists($this,'getSearchList')) {
            $searchList = $this->getSearchList();
        }
        return ResponseData::success($columns, ['search' => $searchList ?? []]);
    }
}